package com.assets.room.dao;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;

import com.assets.room.entity.ReceivesReapply;

import java.util.List;

@Dao
public interface ReceivesReapplyDao {

    @Insert
    void insertReceivesReapply(ReceivesReapply receivesReapply);

    @Insert
    void insertReceivesReapply(List<ReceivesReapply> receivesReapply);

    @Query("DELETE FROM t_asset_receives_reapply")
    void deleteAllData();

    @Query("SELECT sum FROM t_asset_receives_reapply WHERE receives_id = :receives_id")
    String getSumById(Long receives_id);

    @Query("SELECT * FROM t_asset_receives_reapply WHERE is_flag = :is_flag")
    List<ReceivesReapply> getAllById(String is_flag);

    @Query("SELECT * FROM t_asset_receives_reapply WHERE receives_id = :receives_id")
    List<ReceivesReapply> getNameById(String receives_id);

    @Query("SELECT num FROM t_asset_receives_reapply WHERE receives_id = :receives_id")
    List<String> getNameByIds(String receives_id);

    @Query("SELECT num FROM t_asset_receives_reapply WHERE receives_id = :receives_id")
    String getNum(String receives_id);

    @Query("SELECT * FROM t_asset_receives_reapply WHERE receives_id = :receives_id")
    ReceivesReapply getAllByIds(String receives_id);

    @Query("SELECT sum FROM t_asset_receives_reapply WHERE receives_id = :receives_id")
    String getSumById(String receives_id);

    @Query("SELECT sum FROM t_asset_receives_reapply WHERE name = :name")
    String getSumByName(String name);

    @Query("SELECT isaudit FROM t_asset_receives_reapply WHERE receives_id = :receives_id")
    String getSumByIds(String receives_id);

    @Query("UPDATE t_asset_receives_reapply SET isput = :isput, is_flag = :is_flag WHERE receives_id = :receives_id")
    void updateIsAudit(String isput, String is_flag, String receives_id);

    @Query("UPDATE t_asset_receives_reapply SET isput = :isput, is_flag = :is_flag WHERE name = :name")
    void updateIsAudits(String isput, String is_flag, String name);


    @Query("SELECT * FROM t_asset_receives_reapply WHERE isput = :isput AND receives_id = :receives_id")
    List<ReceivesReapply> getOn1Data(String isput, String receives_id);

}
